import $api from "../../api"

export default {
    namespaced:true,
    state: {
        recipeList:[],
    },
    mutations: {
        changeList(state,payload){
            state.slideshowList.splice(0,state.slideshowList.length);
            console.log(state.slideshowList);
            state.slideshowList.push(payload);
            console.log(state.slideshowList);
        }
    },
    actions: {
        //获取菜谱所有信息
        async getAll(context,payload){
            let res =  await $api.recipeRequest.getAllshow(payload);
            // console.log(payload)
            // console.log("获取菜谱所有信息");
            // console.log(res.data);
            context.state.recipeList=res.data.menus
            return res.data
        },
        //搜索
        async searchMenu(context,payload){
            let res =  await $api.recipeRequest.getsearchMenu(payload);
            // console.log("搜索菜谱信息");
            // console.log(res.data);
            context.state.recipeList=res.data.menus
            return res.data
        },
        //详情
        async menuDetail(context,payload){
            let res =  await $api.recipeRequest.getmenuDetail(payload);
            console.log("菜谱详情");
            console.log(res);
            console.log(res.data.message);
            // context.dispatch("getAll")
            return res.data
        },
        //修改
        async updateMenu(context,payload){
            let res =  await $api.recipeRequest.getupdateMenu(payload);
            console.log("修改菜谱信息");
            console.log(res);
            // context.dispatch("getAll")
            return res.data
        },
    }
}